<template>
  <div style="background: #ffffff">
    <flow-panel ref="flowPanel" @editData="edit"></flow-panel>
  </div>
</template>

<script>
import FlowPanel from "@/components/ef/panel";

export default {
  components: {
    FlowPanel,
  },
  async mounted() {
    let id = this.$route.query.id;
    if (!!id) {
      this.$axios.get("/cfflows/" + id).then((res) => {
        this.model = res.data;
        this.$refs.flowPanel.flowInit(JSON.parse(this.model.flowData));
      });
    }
  },
  data() {
    return {
      model: {
        id: "",
        name: "",
        remark: "",
      },
    };
  },
  methods: {
    edit(flowData) {
      let data = this.model;
      data.flowData = JSON.stringify(flowData);
      this.$axios.put("/cfflows/edit", data).then((res) => {
        if (res.data.code == "0000") {
          this.$Message.success(res.data.msg);
        } else {
          this.$Message.error(res.data.msg);
        }
      });
    },
  },
  deactivated() {
    this.$destroy(true);
  },
};
</script>
